<template>
  <h1>El-菜单组件</h1>
  <el-menu mode="horizontal" background-color="#4F8DFE"
           text-color="#fff" active-text-color="#ff0"
           @select="handleSelect">
    <el-menu-item index="1">首页</el-menu-item>
    <el-menu-item index="2">免费课</el-menu-item>
    <el-menu-item index="3">直播课</el-menu-item>
    <el-menu-item index="4">精品课</el-menu-item>
    <el-menu-item index="5">先上班</el-menu-item>
    <el-sub-menu index="6">
      <template #title>线下班</template>
      <el-menu-item index="6-1">JSD2405</el-menu-item>
      <el-menu-item index="6-2">JSD2406</el-menu-item>
      <el-menu-item index="6-3">JSD2407</el-menu-item>
    </el-sub-menu>
  </el-menu>
</template>

<script setup>
//index指的是选择了哪个菜单项，对应该菜单项的index值，比如5表示选择了“线上班”
//indexPath表示选中菜单项的路径，比如[6,6-2]表示选中的是“线下班”下的“JSD2406”
const handleSelect = (index, indexPath) => {
  console.log(index, indexPath)
}
</script>


<style scoped>

</style>